﻿<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="favicon.ico" >
<link rel="Shortcut Icon" href="favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--/meta 作为公共模版分离出去-->

<title>首页</title>

<style>

</style>


</head>
<body>
<!--_header 作为公共模版分离出去-->
<div th:replace="common/header::header"></div>
<!--_menu 作为公共模版分离出去-->
<div th:replace="common/menu::menu"></div>

<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont"></i> <a href="/index" class="maincolor">首页</a>
		<span class="c-999 en">&gt;</span><span class="c-666">个人中心</span>
		<span class="c-999 en">&gt;</span><span class="c-666">用户信息</span>
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<p class="f-20 text-success">欢迎使用教学基地管理系统！</p>
			<p>当前时间：<span id="currentTime"></span></p>

		</article>


		<div class="panel panel-default">
			<div class="panel-header"><span>用户信息</span>
				<input class="btn radius btn-primary" onClick="edit_modal()" type="button" value="修改">
			</div>
			<!--<div class="panel-body">-->
					<!--<ul class="inline ml-30 f-20">-->
						<!--<li class="ml-20">ID:1001</li>-->
						<!--<li class="ml-20">姓名:小川</li>-->
						<!--<li class="ml-20">角色:学生</li>-->
						<!--<li class="ml-20">学院:计科院</li>-->
					<!--</ul>-->
			<!--</div>-->
			<shiro:hasRole name="student">
			<table class="table table-border mt-20">
				<tbody class="text-c">

				<tr>
					<td>基地编号</td>
					<td>基地所属公司</td>
					<td>基地名称</td>
					<td>基地负责老师</td>
					<td>报到地点</td>
					<td>报道日期</td>
				</tr>
				<tr th:if="${base!=null}">
					<td><a th:href="@{/baseDetails}" class="c-primary" th:text="${base.baseId}"></a></td>
					<td th:text="${base.company.companyName}"></td>
					<td th:text="${base.baseName}"></td>
					<td th:text="${base.teacher.teacherName}"></td>
					<td th:text="${base.baseAddress}"></td>
					<td th:text="${#calendars.format(base.baseReportDate,'yyyy-MM-dd HH:mm')}"></td>
				</tr>
				<tr th:if="${base == null}">
					<td colspan="6" style="color: red">
					<h4>未报名校外实训</h4>
				</td>
				</tr>
				</tbody>
			</table>
			</shiro:hasRole>
		</div>
	</div>
</section>
<div id="edit_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content radius">
			<div class="modal-header">
				<h3 class="modal-title">个人信息修改</h3>
				<a class="close" data-dismiss="modal" aria-hidden="true" href="#;">×</a>
			</div>
			<form class="modal-body" id="editUserForm">
				ID：<input type="text" class="input-text radius" disabled="disabled" th:value="${user.username}">
				<input type="hidden" class="input-text radius" name="username" th:value="${user.username}"><br>
				姓名：<input type="text" class="input-text radius "  disabled="disabled" th:value="${user.name}">
				<input type="hidden" class="input-text radius " name="name" th:value="${user.name}"><br>
				学院：<input type="text"  class="input-text radius" disabled="disabled" th:value="${user.college!=null}?${user.college}:${user.company}"><br>
				<input type="hidden"  class="input-text radius" th:name="${user.college!=null}?'college':'company'" th:value="${user.college!=null}?${user.college}:${user.company}">
				姓别：
				<div class="check-box"><input type="radio" id="radio-1" name="sex" th:value="1" th:checked="${user.sex=='1'}">
						<label for="radio-1" class="f-16">男</label>&nbsp;&nbsp;&nbsp;
					<input type="radio" id="radio-2" name="sex" th:value="2" class="size-L" th:checked="${user.sex=='2'}">
						<label for="radio-2" class="f-16">女</label></div><br>
				年龄：<input type="text" class="input-text radius" name="age" th:value="${user.age}" ><br>
				手机号：<input type="text" class="input-text radius" name="phone" th:value="${user.phone}" ><br>
				邮箱：<input type="text" class="input-text radius" name="email" th:value="${user.email}"><br>

			<div class="modal-footer">
				<input type="submit" class="btn btn-primary" value="修改"></input>
				<button class="btn" data-dismiss="modal" aria-hidden="true" id="cancle">取消</button>
			</div>
			</form>
		</div>
	</div>
</div>



<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
	$(function () {
		$("#editUserForm").submit(function () {
			var data = $("#editUserForm").serializeArray();
			$.ajax({
				data:data,
				type:"post",
				url:"/user/updateUser",
				dataType:"json",
				success:function (data) {
					if (data){
						layer.msg("修改成功。");
						setTimeout('window.location.href="/logout"', 1000);
					} else {
						layer.msg("修改失败。");
					}
				}
			});
			return false;
		});

	});

	function edit_modal(){
		$("#edit_modal").modal("show")}
	$(function () {
		setInterval("getNowFormatDate()",1);

	});

	function getNowFormatDate() {
		var date = new Date();
		var seperator1 = "-";
		var seperator2 = ":";
		var month = date.getMonth() + 1;
		var strDate = date.getDate();
		if (month >= 1 && month <= 9) {
			month = "0" + month;
		}
		if (strDate >= 0 && strDate <= 9) {
			strDate = "0" + strDate;
		}
		var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
				+ " " + date.getHours() + seperator2 + date.getMinutes()
				+ seperator2 + date.getSeconds();
		$("#currentTime").html(currentdate);
	}

	$(function () {
		$("#editUserForm").validate({
			rules: {
				phone: {
					minlength: 11,
					maxlength: 11,
					digits: true,//只能填整数
				},
				email: {
					email:true
				}
			},
			messages: {
				phone: {
					minlength: "请正确填写信息",
					maxlength: "请正确填写信息",
					digits: "请正确填写信息"
				},
				email: {
					email: "请正确填写信息"
				}

			}
		})
	});
</script>
<!--/请在上方写此页面业务相关的脚本-->


</body>
</html>
